import type { Video } from "~/composables/apis/types/video";

export const useVideoApi = () => {
  /**
   * 获取短剧列表
   */
  const playletList = () => {
    return useHttp<Video.PlayletType[]>({ url: `/list` });
  };

  /**
   * 获取剧集列表
   */
  const serialList = (id: string) => {
    const { $globalData } = useNuxtApp();
    return useHttp<Video.Serial[]>({
      url: `/serial/list/${$globalData.userId}/${id}`,
    });
  };

  /**
   * 获取剧集地址
   * @serialId 剧集id
   */
  const serialInfo = (serialId: string) => {
    const { $globalData } = useNuxtApp();
    return useHttp<string>({
      url: `/serial/info/${$globalData.userId}/${serialId}`,
    });
  };

  return { playletList, serialList, serialInfo };
};
